package com.hurt.competition.admin.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hurt.competition.admin.dto.StudentReq;
import com.hurt.competition.admin.dto.TeacherReq;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TeacherMapper {
    /**
     * 分页查询所有评委信息
     * @param page
     * @return List<Teacher>
     */
    @Select("select * from judge_info")
    IPage<TeacherReq> findAll(Page page);

    @Select("select * from judge_info where j_id = #{j_id}")
    TeacherReq findById(Integer id);

    @Delete("delete from judge_info where j_id = #{j_id}")
    int deleteById(Integer id);

    /**
     *更新所有评委信息
     * @param teacher 传递一个对象
     * @return 受影响的记录条数
     */
    @Update("update judge_info set name = #{name},sex = #{sex},age = #{age},phone = #{phone}," +
            "email = #{email} " + "where j_id = #{j_id}")
    int update(TeacherReq teacher);

    /**
     * 更新密码
     * @param teacher
     * @return 受影响的记录条数
     */
    @Update("update teacher set pwd = #{pwd} where j_id = #{j_id}")
    int updatePwd(TeacherReq teacher);
}
